How to demonstrate the use of default arguments in PHP | PHP programs
We will calculate the addition of two numbers, here we use the argument of the user define function contains a default value. It means if we will pass the value of the default argument then the default value is used for that parameter.
<?php
function Sum($num1, $num2 = 20)
{
$num3 = $num1 + $num2;
return $num3;
}
$num3 = Sum(10, 30);
echo "Sum: " . $num3 . "<br>";
$num3 = Sum(10);
echo "Sum: " . $num3 . "<br>";
?>


